package org.budo.vms.service.huawei;

import java.io.File;
import java.io.FileInputStream;

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.budo.support.lang.util.PropertiesUtil;
import org.budo.vms.service.api.PlayInfo;

/**
 * @author lmw
 */
public class HuaweiVmsServiceTest_发 {
    public static final String FILE_FROM = "/签名语音，短信提示人员名单2021.01.04.xlsx";

    private static final String DISPLAY_NBR = "+86" + "51668971078";

    public static void main(String[] args) throws Throwable {
        XSSFWorkbook hssfWorkbook = new XSSFWorkbook(new FileInputStream(new File(FILE_FROM)));
        XSSFSheet sheetAt = hssfWorkbook.getSheetAt(0);

        for (int i = 1; i < sheetAt.getPhysicalNumberOfRows(); i++) {
            XSSFRow row = sheetAt.getRow(i);
            XSSFCell cell = row.getCell(2);

            String singleCallByTts = singleCallByTts(cell.toString().trim());

            System.err.println(cell + " > " + singleCallByTts);
        }

        hssfWorkbook.close();
    }

    public static String singleCallByTts(String calleeNumber) {
        HuaweiVmsServiceImpl huaweiVmsService = new HuaweiVmsServiceImpl();
        huaweiVmsService.setAppKey(PropertiesUtil.loadProperty("/huawei-vms.txt", "app_key"));
        huaweiVmsService.setAppSecret(PropertiesUtil.loadProperty("/huawei-vms.txt", "app_secret"));

        PlayInfo playInfo = new HuaweiVoicePlayInfo().setNotifyVoice("download_yst.wav");
        String singleCallByTts = huaweiVmsService.callNotify(DISPLAY_NBR, "+86" + calleeNumber, playInfo);
        return singleCallByTts;
    }
}